home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vbxs / crwvbx02 / publishr.frm < prev    next >
Text File  |  1996-04-08  |  13KB  |  453 lines

  1. VERSION 2.00
  2. Begin Form frmPublishers 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Publishers"
  6.    ClientHeight    =   3504
  7.    ClientLeft      =   2004
  8.    ClientTop       =   2592
  9.    ClientWidth     =   6516
  10.    Height          =   3948
  11.    Icon            =   PUBLISHR.FRX:0000
  12.    Left            =   1944
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   3504
  16.    ScaleWidth      =   6516
  17.    Top             =   2208
  18.    Width           =   6636
  19.    Begin Data Data1 
  20.       Caption         =   "Data1 - BIBLIO.MDB - Publishers"
  21.       Connect         =   ""
  22.       DatabaseName    =   "C:\VB\VBPRO3\BIBLIO.MDB"
  23.       Exclusive       =   0   'False
  24.       Height          =   252
  25.       Left            =   48
  26.       Options         =   0
  27.       ReadOnly        =   0   'False
  28.       RecordSource    =   "Publishers"
  29.       Top             =   2772
  30.       Visible         =   0   'False
  31.       Width           =   4020
  32.    End
  33.    Begin SSPanel pnlSelect 
  34.       BevelInner      =   1  'Inset
  35.       BorderWidth     =   1
  36.       Height          =   684
  37.       Left            =   180
  38.       TabIndex        =   0
  39.       Top             =   150
  40.       Width           =   6156
  41.       Begin SSPanel pnlShortName 
  42.          BevelOuter      =   0  'None
  43.          Height          =   540
  44.          Left            =   3036
  45.          TabIndex        =   25
  46.          Top             =   60
  47.          Width           =   3060
  48.          Begin TextBox txtShortName 
  49.             DataField       =   "Name"
  50.             DataSource      =   "Data1"
  51.             Height          =   288
  52.             Left            =   72
  53.             TabIndex        =   3
  54.             Top             =   144
  55.             Width           =   2868
  56.          End
  57.       End
  58.       Begin ComboBox cmboPubIndex 
  59.          Height          =   288
  60.          Left            =   1596
  61.          Style           =   2  'Dropdown List
  62.          TabIndex        =   2
  63.          Top             =   204
  64.          Width           =   1404
  65.       End
  66.       Begin Label lblIndex 
  67.          Alignment       =   1  'Right Justify
  68.          BackColor       =   &H00C0C0C0&
  69.          Caption         =   "Publisher &Index"
  70.          ForeColor       =   &H00800000&
  71.          Height          =   240
  72.          Left            =   144
  73.          TabIndex        =   1
  74.          Top             =   252
  75.          Width           =   1428
  76.       End
  77.    End
  78.    Begin SSPanel pnlMaster 
  79.       BevelInner      =   1  'Inset
  80.       BorderWidth     =   1
  81.       Height          =   1944
  82.       Left            =   180
  83.       TabIndex        =   4
  84.       Top             =   960
  85.       Width           =   6156
  86.       Begin TextBox txtInfo 
  87.          DataField       =   "Zip"
  88.          DataSource      =   "Data1"
  89.          Height          =   288
  90.          Index           =   4
  91.          Left            =   4800
  92.          TabIndex        =   12
  93.          Top             =   792
  94.          Width           =   1068
  95.       End
  96.       Begin TextBox txtInfo 
  97.          DataField       =   "State"
  98.          DataSource      =   "Data1"
  99.          Height          =   288
  100.          Index           =   3
  101.          Left            =   4296
  102.          TabIndex        =   11
  103.          Top             =   792
  104.          Width           =   468
  105.       End
  106.       Begin TextBox txtInfo 
  107.          DataField       =   "Fax"
  108.          DataSource      =   "Data1"
  109.          Height          =   288
  110.          Index           =   6
  111.          Left            =   1800
  112.          TabIndex        =   16
  113.          Top             =   1440
  114.          Width           =   1350
  115.       End
  116.       Begin TextBox txtInfo 
  117.          DataField       =   "Telephone"
  118.          DataSource      =   "Data1"
  119.          Height          =   288
  120.          Index           =   5
  121.          Left            =   1800
  122.          TabIndex        =   14
  123.          Top             =   1116
  124.          Width           =   1350
  125.       End
  126.       Begin TextBox txtInfo 
  127.          DataField       =   "City"
  128.          DataSource      =   "Data1"
  129.          Height          =   288
  130.          Index           =   2
  131.          Left            =   1800
  132.          TabIndex        =   10
  133.          Top             =   792
  134.          Width           =   2460
  135.       End
  136.       Begin TextBox txtInfo 
  137.          DataField       =   "Address"
  138.          DataSource      =   "Data1"
  139.          Height          =   288
  140.          Index           =   1
  141.          Left            =   1800
  142.          TabIndex        =   8
  143.          Top             =   468
  144.          Width           =   4070
  145.       End
  146.       Begin TextBox txtInfo 
  147.          DataField       =   "Company Name"
  148.          DataSource      =   "Data1"
  149.          Height          =   288
  150.          Index           =   0
  151.          Left            =   1800
  152.          TabIndex        =   6
  153.          Top             =   144
  154.          Width           =   4070
  155.       End
  156.       Begin Label lblInfo 
  157.          Alignment       =   1  'Right Justify
  158.          BackColor       =   &H00C0C0C0&
  159.          Caption         =   "&FAX Number"
  160.          ForeColor       =   &H00800000&
  161.          Height          =   288
  162.          Index           =   4
  163.          Left            =   216
  164.          TabIndex        =   15
  165.          Top             =   1440
  166.          Width           =   1500
  167.       End
  168.       Begin Label lblInfo 
  169.          Alignment       =   1  'Right Justify
  170.          BackColor       =   &H00C0C0C0&
  171.          Caption         =   "Phone &Number"
  172.          ForeColor       =   &H00800000&
  173.          Height          =   288
  174.          Index           =   3
  175.          Left            =   216
  176.          TabIndex        =   13
  177.          Top             =   1116
  178.          Width           =   1500
  179.       End
  180.       Begin Label lblInfo 
  181.          Alignment       =   1  'Right Justify
  182.          BackColor       =   &H00C0C0C0&
  183.          Caption         =   "&City, State ZIP"
  184.          ForeColor       =   &H00800000&
  185.          Height          =   288
  186.          Index           =   2
  187.          Left            =   216
  188.          TabIndex        =   9
  189.          Top             =   792
  190.          Width           =   1500
  191.       End
  192.       Begin Label lblInfo 
  193.          Alignment       =   1  'Right Justify
  194.          BackColor       =   &H00C0C0C0&
  195.          Caption         =   "&Address"
  196.          ForeColor       =   &H00800000&
  197.          Height          =   288
  198.          Index           =   1
  199.          Left            =   216
  200.          TabIndex        =   7
  201.          Top             =   468
  202.          Width           =   1500
  203.       End
  204.       Begin Label lblInfo 
  205.          Alignment       =   1  'Right Justify
  206.          BackColor       =   &H00C0C0C0&
  207.          Caption         =   "Company &Name"
  208.          ForeColor       =   &H00800000&
  209.          Height          =   288
  210.          Index           =   0
  211.          Left            =   216
  212.          TabIndex        =   5
  213.          Top             =   144
  214.          Width           =   1500
  215.       End
  216.    End
  217.    Begin SSPanel pnlAction 
  218.       Align           =   2  'Align Bottom
  219.       Height          =   420
  220.       Left            =   0
  221.       TabIndex        =   17
  222.       Top             =   3084
  223.       Width           =   6516
  224.       Begin SSCommand cmdAction 
  225.          BevelWidth      =   1
  226.          Caption         =   "&E&xit"
  227.          Height          =   400
  228.          Index           =   6
  229.          Left            =   5568
  230.          TabIndex        =   24
  231.          Top             =   12
  232.          Width           =   920
  233.       End
  234.       Begin SSCommand cmdAction 
  235.          BevelWidth      =   1
  236.          Caption         =   "&Print"
  237.          Height          =   400
  238.          Index           =   5
  239.          Left            =   4644
  240.          TabIndex        =   23
  241.          Top             =   12
  242.          Width           =   920
  243.       End
  244.       Begin SSCommand cmdAction 
  245.          BevelWidth      =   1
  246.          Caption         =   "&Save"
  247.          Enabled         =   0   'False
  248.          Height          =   400
  249.          Index           =   4
  250.          Left            =   3720
  251.          TabIndex        =   22
  252.          Top             =   12
  253.          Width           =   920
  254.       End
  255.       Begin SSCommand cmdAction 
  256.          BevelWidth      =   1
  257.          Caption         =   "&Cancel"
  258.          Enabled         =   0   'False
  259.          Height          =   400
  260.          Index           =   3
  261.          Left            =   2796
  262.          TabIndex        =   21
  263.          Top             =   12
  264.          Width           =   920
  265.       End
  266.       Begin SSCommand cmdAction 
  267.          BevelWidth      =   1
  268.          Caption         =   "&Edit"
  269.          Height          =   400
  270.          Index           =   2
  271.          Left            =   1872
  272.          TabIndex        =   20
  273.          Top             =   12
  274.          Width           =   920
  275.       End
  276.       Begin SSCommand cmdAction 
  277.          BevelWidth      =   1
  278.          Caption         =   "&Delete"
  279.          Height          =   400
  280.          Index           =   1
  281.          Left            =   948
  282.          TabIndex        =   19
  283.          Top             =   12
  284.          Width           =   920
  285.       End
  286.       Begin SSCommand cmdAction 
  287.          BevelWidth      =   1
  288.          Caption         =   "&New"
  289.          Height          =   400
  290.          Index           =   0
  291.          Left            =   24
  292.          TabIndex        =   18
  293.          Top             =   12
  294.          Width           =   920
  295.       End
  296.    End
  297. End
  298. Option Explicit
  299. DefInt A-Z
  300.  
  301. Sub ActionToggle (EditStatus As Integer)
  302.   
  303.   pnlMaster.Enabled = EditStatus
  304.   pnlShortName.Enabled = EditStatus
  305.   cmboPubIndex.Enabled = Not EditStatus
  306.   
  307.   cmdAction(0).Enabled = Not EditStatus
  308.   cmdAction(1).Enabled = Not EditStatus
  309.   cmdAction(2).Enabled = Not EditStatus
  310.   cmdAction(3).Enabled = EditStatus
  311.   cmdAction(4).Enabled = EditStatus
  312.   cmdAction(5).Enabled = Not EditStatus
  313.   cmdAction(6).Enabled = Not EditStatus
  314.  
  315. End Sub
  316.  
  317. Sub cmboPubIndex_Click ()
  318.  
  319.   Data1.Recordset.FindFirst "[PubID] = " & cmboPubIndex
  320.  
  321. End Sub
  322.  
  323. '
  324. '  This routine is usually the hub of my programs.  I've standardized on
  325. '  the toolbar buttons named 'cmdAction'.  It makes it easier for others
  326. '  to follow behind me later (myself included).  We always know where the
  327. '  'central control' routine is located.
  328. '
  329. '  I normally use Sheridan bound Combo boxes and don't have to update the
  330. '  ListIndex property.  This was the first time I had to do the extra
  331. '  coding to maintain the Combo, and there may be a better way.
  332. '
  333. Sub cmdAction_Click (Index As Integer)
  334.  
  335.   Static NewRecordInProgress As Integer
  336.   Dim Temp As Long
  337.   
  338.   Select Case Index
  339.     
  340.     Case 0 'Add New Record
  341.       Call ActionToggle(True)
  342.       BeginTrans
  343.       Data1.Recordset.MoveLast
  344.       Temp = Data1.Recordset("PubId") + 1
  345.       cmboPubIndex.AddItem Trim$(Str$(Temp))
  346.       cmboPubIndex.ListIndex = Data1.Recordset.RecordCount
  347.       Data1.Recordset.AddNew
  348.       Data1.Recordset("PubID") = Temp
  349.       NewRecordInProgress = True
  350.     
  351.     Case 1 'Delete Current Record
  352.       BeginTrans
  353.       If VerifyDeleteRecord() Then
  354.         Data1.Recordset.Delete
  355.         Temp = cmboPubIndex.ListIndex
  356.         cmboPubIndex.RemoveItem cmboPubIndex.ListIndex
  357.         If Temp <= cmboPubIndex.ListCount - 1 Then
  358.           cmboPubIndex.ListIndex = Temp
  359.         Else
  360.           cmboPubIndex.ListIndex = Temp - 1
  361.         End If
  362.         Call cmdAction_Click(4)
  363.       End If
  364.     
  365.     Case 2 'Edit Current Record
  366.       Call ActionToggle(True)
  367.       BeginTrans
  368.     
  369.     Case 3 'Cancel current operation
  370.       Call ActionToggle(False)
  371.       Rollback
  372.       If NewRecordInProgress Then
  373.         cmboPubIndex.RemoveItem cmboPubIndex.ListIndex
  374.         NewRecordInProgress = False
  375.       End If
  376.       Data1.Refresh
  377.       cmboPubIndex.ListIndex = 0
  378.     
  379.     Case 4 'Commit current operation
  380.       Call ActionToggle(False)
  381.       Data1.UpdateRecord
  382.       CommitTrans
  383.       If NewRecordInProgress Then
  384.         Data1.Recordset.MoveLast
  385.         cmboPubIndex.ListIndex = cmboPubIndex.ListCount - 1
  386.         NewRecordInProgress = False
  387.       End If
  388.     
  389.     Case 5 'Print a report
  390.       Call PrintReport
  391.     
  392.     Case 6 'Terminate program
  393.       Call ProgramShutDown
  394.     
  395.     Case Else
  396.   
  397.   End Select
  398.  
  399. End Sub
  400.  
  401. Sub Form_Activate ()
  402.  
  403.   Call ActionToggle(False)
  404.   Call LoadPublisherCombo
  405.  
  406. End Sub
  407.  
  408. Sub Form_Load ()
  409.  
  410.   Dim rc As Integer
  411.  
  412.   On Local Error GoTo frmPublisherLoadError
  413.   Call InitFormDataControls(Me)
  414.   Call CenterForm(Me)
  415.   Exit Sub
  416.  
  417. frmPublisherLoadError:
  418.   rc = CriticalErrorHandler(Err)
  419.   Exit Sub
  420.  
  421. End Sub
  422.  
  423. Sub LoadPublisherCombo ()
  424.   
  425.   'get the list of Publishers for the dropdown combo
  426.   'Dim ds As Dynaset
  427.   Data1.Refresh
  428.   Set ds = Data1.Recordset.CreateDynaset()
  429.   ds.MoveLast
  430.   ds.MoveFirst
  431.   If ds.RecordCount > 0 Then
  432.     Do
  433.       cmboPubIndex.AddItem ds("PubID")
  434.       ds.MoveNext
  435.     Loop Until ds.EOF
  436.   End If
  437.   cmboPubIndex.ListIndex = 0
  438.   
  439.   ds.Close
  440.  
  441. End Sub
  442.  
  443. Sub PrintReport ()
  444.  
  445.   'ds is a global DynaSet
  446.   
  447.   Screen.MousePointer = HOURGLASS
  448.   Set ds = Data1.Recordset.CreateDynaset()
  449.   frmPrinter.Show MODAL
  450.  
  451. End Sub
  452.  
  453.